#include "string_study.h"

#include <iostream>
using namespace std;
#include <cstring>


void stringStudy(){
    cout << "stringStudy ==================  " << endl;

    string s = "Hello World";

    cout << "s[0]: " << s[0] << endl;
    cout << "s.at(1): " << s.at(1) << endl;
    cout << "s.front(): " << s.front() << endl;
    cout << "s.back(): " << s.back() << endl;
    s.front()='7';
    cout << "s: " << s << endl;

    cout << "typeid: " << typeid(stringStudy).name() << endl;

    string s2 = "!";

    cout << "s+s2: " << s+s2 << endl;

    cout << "s.append: " << s.append("!") << endl;


    cout << "s: " << s << endl;


    string str = "JAVA C C++ PYTHON";
    str+="!";

    cout << "str+=: " << str << endl;

    str.append("!");

    cout << "str.append: " << str << endl;

    s.insert(0,"Tom ").replace(4,1,"H");
    

    cout << "s: " << s << endl;

    cout << "erase: " << s.erase(0,4) << endl;
    
    s.swap(str);

    cout << "s swap: " << s << " | " << str << endl;

    string substr = s.substr(5,1);

    cout << "substr: " << substr << endl;

    string substr2 = s.substr(5);

    cout << "substr2: " << substr2 << endl;

    cout << "s.lenght: " << s.length()<< endl;

    cout << "s.size: " << s.size()<< endl;

    // s.erase(0);
    s.clear();

    cout << "s.empty: " << s.empty() << endl;


    const char * cs = str.c_str();


    cout << " str.length: " << str.length() << " str.c_str.length: " << strlen(cs) << endl;


    cout << " str.find: " << str.find("C++") << " npos: " << string::npos << endl;

    size_t pos = s.find("C++");
    if(pos == string::npos){
        cout << "C++ not found" << endl;
    }


    string sx1("Hello"),sx2("Hello");

    cout << " sx1 compare sx2 : " << sx1.compare(sx2) << endl;

    

    



 

}
